<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>任务内容</title>
    <script type="text/javascript" src="/js/jquery.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
</head>
<body>
<div>
    <div id="J_title">标题：</div>
    <div id="J_rule">规则：</div>
    <div id="J_pic"></div>
    <div id="J_time">有效时间:</div>
    <div id="J_content"></div>
    <div id="J_readed">阅读量:</div>
</div>
<script>

    var title = "";
    var desc = "";
    var link = "";
    var pic = "";
    wx.config({
        debug: false,
        appId: "${appId}",
        timestamp: "${timestamp}",
        nonceStr: "${nonceStr}",
        signature: "${signature}",
        jsApiList: [
            //所有要调用的 API 都要加到这个列表中
            "onMenuShareAppMessage",
            "updateAppMessageShareData",
            "updateTimelineShareData"
        ]
    });


    wx.ready(function () {   //需在用户可能点击分享按钮前就先调用
        wx.onMenuShareAppMessage({
            title: title, // 分享标题
            desc: desc, // 分享描述
            link: link, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
            imgUrl: pic, // 分享图标
            type: 'link', // 分享类型,music、video或link，不填默认为link
            success: function (res) {
                alert('分享成功');
            },
            cancel: function (res) {
                alert('分享失败');
                // 用户取消分享后执行的回调函数
            },
        });

     wx.onMenuShareTimeline({
        title: '这是分享的标题', // 分享标题
        link: 'http://166xj71935.51mypc.cn/index.php/', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
        imgUrl: 'http://img1.3lian.com/img013/v2/4/d/101.jpg', // 分享图标
         success: function (res) {
             alert('分享成功');
         },
         cancel: function (res) {
             alert('分享失败');
             // 用户取消分享后执行的回调函数
         },
     });


    });





    $(function(){
        var id = "${id}";
        getTaskDetail(id)
    });


    function getTaskDetail(id){
        var data = {id:id};
        var url = "/task/getTaskInfo";
        $.ajax({
            type: "POST",
            async: false,
            dataType: 'json',
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(data),
            url: url,
            success: function(res){
                if(res.code == 200){
                    var datas = res.data;
                     $("#J_title").append(datas.title);
                     $("#J_rule").append(datas.rule);
                     $("#J_pic").append('<img src = "'+datas.pic+'">');
                     $("#J_time").append(datas.start_time+"--"+datas.end_time);
                     $("#J_content").append(datas.content);
                     $("#J_readed").append(datas.readed);
                     title = datas.title;
                     desc = datas.rule;
                     pic = datas.pic;
                    link = window.location.href;
                }else{
                    alert(res.msg);
                }
            },
            error: function(){

            },
            complete: function(){
            }
        });
    }



</script>
</body>
</html>
